﻿using System;
using System.Windows;
using System.Windows.Data;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace VideoReflector.Converters
{
    /// <summary>
    /// Value Converter which takes a resource key as input and returns the corresponding (application-scoped) resource
    /// </summary>
    [ValueConversion(typeof(object), typeof(object))]
    public class KeyToResourceConverter : ConverterWithMarkupExtension, IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            if (value == null || !Application.Current.Resources.Contains(value))
                return Binding.DoNothing;
            else
                return Application.Current.Resources[value];
        }

        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            throw new NotImplementedException();
        }
    }
}
